<template>
  <ul class="chanpin">
    <li v-for="item in goodsList" :key="item.id" @click="goDetailPage(item.id)">
      <img v-lazy="item.list_pic_url" alt="" />
      <h3>{{ item.name }}</h3>
      <section>{{ item.retail_price | filterMoney }}</section>
    </li>
  </ul>
</template>

<script>
export default {
  props: ["goodsList"],
  data() {
    return {};
  },
  methods: {
    goDetailPage(id) {
      this.$router.push(`/detail/${id}`);
    },
  },
};
</script>
 
<style lang = "less" scoped>
.chanpin {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 20px;
  li {
    width: 48%;
    background: #fff;
    text-align: center;
    margin-bottom: 20px;
    img {
      width: 100%;
      display: block;
    }
    h3 {
      font-size: 14px;
      /* 超出一行变省略号 */
      overflow: hidden;
      width: 100%;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    section {
      color: darkred;
    }
  }
}
</style>